import random
import string

def generate_8digit_passwords(count=100):
    """生成8位数字密码"""
    passwords = set()
    while len(passwords) < count:
        pwd = ''.join(random.choices(string.digits, k=8))
        passwords.add(pwd)
    return passwords

def generate_8char_passwords(count=1000):
    """生成8位大小写字母密码"""
    passwords = set()
    while len(passwords) < count:
        pwd = ''.join(random.choices(string.ascii_letters, k=8))
        passwords.add(pwd)
    return passwords

def generate_common_passwords():
    """生成常见密码组合"""
    common = [
        "12345678",
        "88888888",
        "00000000",
        "11111111",
        "password",
        "admin123",
        "87654321",
        "qwerty12",
    ]
    return set(common)

def main():
    # 生成所有类型的密码
    digit_passwords = generate_8digit_passwords(100)
    char_passwords = generate_8char_passwords(1000)
    common_passwords = generate_common_passwords()
    
    # 合并所有密码
    all_passwords = digit_passwords | char_passwords | common_passwords
    
    # 写入文件
    with open('wifi_password_dict.txt', 'w', encoding='utf-8') as f:
        # 写入常见密码（放在最前面优先测试）
        f.write('\n'.join(sorted(common_passwords)))
        f.write('\n')
        # 写入8位数字密码
        f.write('\n'.join(sorted(digit_passwords)))
        f.write('\n')
        # 写入8位字母密码
        f.write('\n'.join(sorted(char_passwords)))

    print(f"已生成密码字典，共 {len(all_passwords)} 个密码")
    print(f"- 常见密码: {len(common_passwords)} 个")
    print(f"- 8位数字密码: {len(digit_passwords)} 个")
    print(f"- 8位字母密码: {len(char_passwords)} 个")

if __name__ == '__main__':
    main() 